load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "metering",
    srcs = [
        "data.go",
        "metering.go",
        "recorder.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/disttask/framework/metering",
    visibility = ["//visibility:public"],
    deps = [
        "//br/pkg/storage/recording",
        "//pkg/config/kerneltype",
        "//pkg/disttask/framework/proto",
        "//pkg/util/logutil",
        "@com_github_docker_go_units//:go-units",
        "@com_github_google_uuid//:uuid",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_metering_sdk//common",
        "@com_github_pingcap_metering_sdk//config",
        "@com_github_pingcap_metering_sdk//storage",
        "@com_github_pingcap_metering_sdk//writer",
        "@com_github_pingcap_metering_sdk//writer/metering",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "metering_test",
    timeout = "short",
    srcs = [
        "data_test.go",
        "metering_test.go",
        "recorder_test.go",
    ],
    embed = [":metering"],
    flaky = True,
    shard_count = 10,
    deps = [
        "//pkg/config/kerneltype",
        "//pkg/disttask/framework/proto",
        "@com_github_pingcap_metering_sdk//common",
        "@com_github_pingcap_metering_sdk//config",
        "@com_github_pingcap_metering_sdk//reader/metering",
        "@com_github_pingcap_metering_sdk//storage",
        "@com_github_pingcap_metering_sdk//writer/metering",
        "@com_github_pingcap_metering_sdk//writer/mock",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_mock//gomock",
        "@org_uber_go_zap//:zap",
    ],
)
